<%@page import="models.StaffModel"%>
<%@page import="java.util.TreeMap"%>
<%@page import="helpers.UrlHelper"%>

<%
TreeMap check = (TreeMap) request.getAttribute("check");
String success = (String) request.getAttribute("success");
StaffModel user = (StaffModel) request.getAttribute("user");
String form = (String) request.getAttribute("form");
%>

<jsp:include page="/admin/demo/layouts/header.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>
<script type="text/javascript" src="/admin/demo/js/form_staff.js"></script>
<script type="text/javascript">
var server = "<%=UrlHelper.getServerUrl(request)%>";
</script>
	<% if (success != null) {%>
	<div class="success block" ><%=success %></div>
	<% } %>
	<div class="block">
		<form id="edit_user_form" action="" method="post">
			<div id="add_items">
				<table class="formPage">
					<thead>
						<tr>
							<th colspan="2">
								User Form
							</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td class="label"><label for="u_username">Tên truy cập:</label></td>
							<td class="smallDesc type">
								<% if (check.get("username") != null) { %>
									<span class="error"><%=check.get("username") %></span>
								<% } %>
								<% if (form.equalsIgnoreCase("edit")) { %>
									<span style="font-size: 14px;"><%=user.getUsername() != null ? user.getUsername() : "" %></span>
								<% } else { %>
								<input id="u_username" class="text" type="text" name="username" value="<%=user.getUsername() != null ? user.getUsername() : "" %>" maxlength="100">
								<% } %>
							</td>
						</tr>
						<% if (form.equalsIgnoreCase("add")) { %>
						<tr>
							<td class="label"><label for="u_password">Mật khẩu:</label></td>
							<td class="smallDesc type">
								<% if (check.get("password") != null) { %>
									<span class="error"><%=check.get("password") %></span>
								<% } %>
								<input id="u_password" class="text" type="password" name=password value="" maxlength="100">
							</td>
						</tr>
						<tr>
							<td class="label"><label for="u_repassword">Nhập lại mật khẩu:</label></td>
							<td class="smallDesc type">
								<% if (check.get("repassword") != null) { %>
									<span class="error"><%=check.get("repassword") %></span>
								<% } %>
								<input id="u_password" class="text" type="password" name=repassword value="" maxlength="100">
							</td>
						</tr>
						<% } %>
					</tbody>
				</table>
				<table class="formPage">
					<tbody>
						<tr>
							<td class="label"><label for="u_name">Full name:</label></td>
							<td class="smallDesc type">
								<% if (check.get("name") != null) { %>
									<span class="error"><%=check.get("name") %></span>
								<% } %>
								<input id="u_fullname" class="text" type="text" name="name" value="<%=user.getName()%>" maxlength="100">
							</td>
						</tr>
						<tr>
							<td class="label"><label for="u_status">Status:</label></td>
							<td class="smallDesc type">
								<% if (check.get("status") != null) { %>
									<span class="error"><%=check.get("status") %></span>
								<% } %>
								<select id="u_status" class="text" name="status">
									<option value="0" <%=user.getStatus() == 0 ? "selected=\"selected\"" : "" %>>Inactive</option>
									<option value="1" <%=user.getStatus() == 1 ? "selected=\"selected\"" : "" %>>Pending</option>
									<option value="2" <%=user.getStatus() == 2 ? "selected=\"selected\"" : "" %>>Active</option>
								</select>
							</td>
						</tr>
						<tr>
							<td class="label"><label for="u_role">Role Access:</label></td>
							<td class="smallDesc type">
								<% if (check.get("role") != null) { %>
									<span class="error"><%=check.get("role") %></span>
								<% } %>
								<select id="u_role" class="text" name="role">
									<option value="0" <%=user.getRole() == 0 ? "selected=\"selected\"" : ""%>>Sale</option>
									<option value="1" <%=user.getRole() == 1 ? "selected=\"selected\"" : ""%>>Bán hàng trực tiếp</option>
									<option value="2" <%=user.getRole() == 2 ? "selected=\"selected\"" : ""%>>Giao nhận</option>
									<option value="3" <%=user.getRole() == 3 ? "selected=\"selected\"" : ""%>>Kho</option>
									<option value="4" <%=user.getRole() == 4 ? "selected=\"selected\"" : ""%>>Điều phối, xuất tuyến</option>
									<option value="5" <%=user.getRole() == 5 ? "selected=\"selected\"" : ""%>>Kế toán</option>
									<option value="6" <%=user.getRole() == 6 ? "selected=\"selected\"" : ""%>>Marketing</option>
									<option value="7" <%=user.getRole() == 7 ? "selected=\"selected\"" : ""%>>CEO</option>
									<option value="8" <%=user.getRole() == 8 ? "selected=\"selected\"" : ""%>>Admin quản trị hệ thống</option>
								</select>
							</td>
						</tr>
					</tbody>
				</table>
				
				<table class="formPage">
					<tfoot>
						<tr>
							<td><input type="reset" class="button" title="Reset form" alt="Reset form" value="Reset" name="reset" id="reset-user-submit"></td>
							<td><input type="submit" class="button" title="Save link" alt="Save form" value="Save" name="save" id="send-user-submit"></td>
						</tr>
					</tfoot>
				</table>
			</div>
		</form>
	</div>

<jsp:include page="/admin/demo/layouts/footer.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>